package org.moonlight.jvm.instructions.constants;

import org.moonlight.jvm.instructions.base.BytecodeReader;
import org.moonlight.jvm.instructions.base.Instruction;
import org.moonlight.jvm.rtda.exclusive.Frame;

/**
 * SIPUSH: 从操作数中获取一个 short 型整数，扩展成 int 型，然后推入栈顶
 *
 * @author Moonlight
 * @createTime 2023/8/16 14:58
 **/
public class SiPush implements Instruction {

    private short val;

    @Override
    public void fetchOperands(BytecodeReader reader) {
        this.val = (short) reader.readInt16();
//        this.val = reader.readShort();
    }

    @Override
    public void execute(Frame frame) {
        frame.getOperandStack().pushInt(this.val);
    }
}
